// 返回红绿码颜色
export function getScoreColor(score){
  // 红绿码规则
  const rule = {
    0:'<60',
    1:'<100',
    2:'>=100'
  }
  const numb = parseInt(score)
  const green = (numb < rule[0].replace(/[^0-9]/ig,""))
  if(green) return 'green'
  
  const orange = (numb < rule[1].replace(/[^0-9]/ig,""))
  if(orange) return 'orange'
  
  const red = (numb >= rule[2].replace(/[^0-9]/ig,""))
  console.log('red',numb,rule[2].replace(/[^0-9]/ig,""),red)
  if(red) return 'red'
}

export function getYMD (day = 0,separator='-') {
  console.log('enter1')
  let dateObj = new Date();
  const whichDay = 1000 * 60 * 60 * 24 * day;
  
  dateObj.setTime(dateObj.getTime() + whichDay);
  const Y = dateObj.getFullYear();
  const M = dateObj.getMonth() + 1;
  const MM = M < 10 ? '0'.concat(M) : M;
  const D = dateObj.getDate() < 10 ? ('0' + dateObj.getDate()) : dateObj.getDate();
  const YMD = Y + separator + MM + separator + D;
  return YMD;
}
// 默认返回今天的 年-月-日 格式,'1'表示明天,'-1'表示昨天
export function todayYMD(day = 0,separator='-') {
    console.log('enter1')
    let dateObj = new Date();
    const whichDay = 1000 * 60 * 60 * 24 * day;

    dateObj.setTime(dateObj.getTime() + whichDay);
    const Y = dateObj.getFullYear();
    const M = dateObj.getMonth() + 1;
    const MM = M < 10 ? '0'.concat(M) : M;
    const D = dateObj.getDate() < 10 ? ('0' + dateObj.getDate()) : dateObj.getDate();
    const YMD = Y + separator + MM + separator + D;
    return YMD;
}